define(function(require, exports, module) {
	"use strict";

	var baseService = require('Base_Service');
	// 控制器名
	exports.controller = "StudyLogs";
	
	/* 获取可用时间 */
	exports.canusetime = function(data ,success) {
		return baseService.post(
			baseService.getApiUrl(exports.controller, "UseableTimes"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	};
	
	/* 筛选教练列表 */
	exports.getCoachs = function(schoolId, placeId, type, isExam,success) {
		var data = {
			'DrivingID' : schoolId,
			'PlaceID' : placeId,
			'CourseType' : type,
			'isExam' : isExam
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller, "SelectCoach"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	};
	
	/**
	 * 预约学习 
	 * @param {Object} data
	 * @param {Object} success
	 */
	exports.add = function(data,success){
		return baseService.post(
			baseService.getApiUrl(exports.controller, "Add"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	}
	
	exports.cancel = function(data,success){
		return baseService.get(
			baseService.getApiUrl(exports.controller, "Cancel"),
			data,
			function(retval) {
				success && success(retval);
			}
		);
	}
	
	/**
	 * 预约记录
	 * @param {Object} currpage
	 * @param {Object} pageSize
	 * @param {Object} success
	 */
	exports.order_study_list = function(isScore,currpage,pageSize,success){
		
		var data = {
			pageIndex: currpage,
			pageSize: pageSize,
			isScore:isScore
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller,'List')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
	/**
	 * 教练记录
	 * @param {Object} currpage
	 * @param {Object} pageSize
	 * @param {Object} success
	 */
	exports.coachTeachList = function(date,success){
		
		var data = {
			pageIndex: 0,
			pageSize: 1000,
			Date:date
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller,'Coach/List')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
	exports.edit = function(data,success){
		return baseService.post(
			baseService.getApiUrl(exports.controller,'Edit')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
	
	exports.coachConfirm = function(id,success){
		var data = {
			StudyLogID : id
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller,'Coach/Confirm')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
	exports.coachStarList = function(page,pageSize,success){
		
		var data = {
			pageIndex: page,
			pageSize: pageSize,
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller,'Coach/StarList')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
	exports.star = function(id,score,success){
		var data = {
			StudyLogID:id,
			Stars:score
		};
		return baseService.post(
			baseService.getApiUrl(exports.controller,'Stars')	,
			data,
			function(retval){
				success && success(retval);
			}
		);
	}
	
});